<template>
    <div>
        <el-row >
           <el-col :span="24">
            <el-form   class="demo-form-inline">
              <el-form-item >
                  <el-input  placeholder="请输入融资企业名称" v-model="financeName" style="float:left;width:300px;margin-left:200px"></el-input>
                  <el-input  placeholder="请输入核心企业名称" v-model="coreName" style="float:left;width:300px;margin-left:10px"></el-input>
                  <el-button icon="el-icon-search"  type="primary"  style="float:left" @click="doSearchBtn"></el-button>
               </el-form-item>
                 </el-form>
                 
           </el-col>
    </el-row>

    <el-row>
      <el-col :span="24">
        <el-table
        :data="tableData"
        border
        style="width: auto;">
        <el-table-column
        type="index"
        label="序号"
        align="center"
        width="50"
    ></el-table-column>
    <el-table-column
        prop="tenderId"
        label="标的编号"
        align="center">
    </el-table-column>
    <el-table-column
        prop="financeName"
      label="融资企业名称"
      align="center"
      >
      <template slot-scope="scope">
        <el-link type="primary" @click="doSee(scope.row)">{{ scope.row.financeName }}</el-link>
      </template>
    </el-table-column>
    <el-table-column
      label="核心企业名称"
      align="center"
      >
      <template slot-scope="scope">
        <el-link type="primary" @click="seeCore(scope.row)">{{ scope.row.coreName }}</el-link>
      </template>
    </el-table-column>
    <el-table-column
    prop="allFinancingAmount"
      label="融资金额(元)"
      align="center">
    </el-table-column>
    <el-table-column
      prop="financingLimit"
      label="融资期限(天)"
      align="center">
    </el-table-column>
    <el-table-column
      prop="annualizedInterestRate"
      label="年化利率(%)"
      align="center">
    </el-table-column>
    <el-table-column
      label="背书凭证"
      align="center">
      <template slot-scope="scope">
        <img :src="scope.row.tenderImages" style="width:120px;heigth:150px">
      </template>
    </el-table-column>
    <el-table-column
      prop="tenderIssuanceTime"
      label="发标时间"
      align="center">
    </el-table-column>
   
    <el-table-column
    label="操作"
    align="center"
    width="500">
    <template slot-scope="scope">
      <el-button type="primary" @click="pass(scope.row)">通过</el-button>
      <el-button type="danger" @click="noPass(scope.row)">不通过</el-button>
    </template>
    </el-table-column>
  </el-table>
      </el-col>
    </el-row>

    <el-row>
           <el-col :span="24" :offset="6">
            <el-pagination
              
              background
              @size-change="sizeChange"
              @current-change="currentChange"
              :current-page="pageNum"
              :page-sizes="[3, 6, 9]"
              :page-size="pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="total">
            </el-pagination>
            </el-col>
        </el-row>
        <el-dialog  title="融资企业详情" :visible.sync="dialogFormVisible" >
    <el-row>
      <el-col :span="10" >
        <el-form :model="dialogform" style="font-size:35px">
          <el-form-item label="企业编码:" label-width="80px">
             <template>{{ dialogform.enterpriseId }}</template>
           </el-form-item>
          <el-form-item label="企业名称:" label-width="80px">
            <template>{{ dialogform.enterpriseName }}</template>
          </el-form-item>
          <el-form-item label="法人:" label-width="80px">
            <template>{{ dialogform.legal }}</template>
          </el-form-item>
          <el-form-item label="手机号:" label-width="80px">
            <template>{{ dialogform.legalPhone }}</template>
          </el-form-item>
          <el-form-item label="身份证号:" label-width="80px">
            <template>{{ dialogform.legalId }}</template>
          </el-form-item>
          <el-form-item label="营业执照图片:" label-width="80px">
            <img :src="dialogform.businessLicenseImage" style="width:300px;heigth:350px"/>
          </el-form-item>
          <el-form-item label="营业执照号:" label-width="80px">
            <template>{{ dialogform.businessLicense }}</template>
            
          </el-form-item>
          <el-form-item label="注册资金:" label-width="80px">
            <template>{{ dialogform.registeredCapital }}</template>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
  
  <div slot="footer" class="dialog-footer">
    <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
  </div>
  </el-dialog>

  <el-dialog  title="核心企业详情" :visible.sync="dialogFormCore" >
    <el-row>
      <el-col :span="10" >
        <el-form :model="coreform" style="font-size:35px">
          <el-form-item label="企业编码:" label-width="80px">
             <template>{{ coreform.coreId }}</template>
           </el-form-item>
          <el-form-item label="企业名称:" label-width="80px">
            <template>{{ coreform.enterpriseName }}</template>
          </el-form-item>
          <el-form-item label="法人:" label-width="80px">
            <template>{{ coreform.legalPerson }}</template>
          </el-form-item>
          <el-form-item label="手机号:" label-width="80px">
            <template>{{ coreform.legalPhone }}</template>
          </el-form-item>
          <el-form-item label="身份证号:" label-width="80px">
            <template>{{ coreform.legalCard }}</template>
          </el-form-item>
          <el-form-item label="营业执照号:" label-width="80px">
            <template>{{ coreform.businessLicense }}</template>
            
          </el-form-item>
          <el-form-item label="注册资金:" label-width="80px">
            <template>{{ coreform.registeredCapital }}</template>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
  
  <div slot="footer" class="dialog-footer">
    <el-button type="primary" @click="dialogFormCore = false">确 定</el-button>
  </div>
  </el-dialog>
    </div>
    
</template>

<script>
export default {
        data(){
            return{
              dialogFormCore:false,
                dialogFormVisible:false,
                tableData:[],
                pageNum:1,
                pageSize:3,
                total:0,
                financeName:'',
                coreName:'',
                dialogform:{
                    enterpriseId:'',
                    enterpriseName:'',
                    legal:'',
                    legalPhone:'',
                    legalId:'',
                    businessLicenseImage:'',
                    businessLicense:'',
                    registeredCapital:'',
                    platformState:'',
                    coreState:''
                },
                coreform:{
                  coreId:'',
                  legalPerson:'',
                  legalPhone:'',
                  legalCard:'',
                  businessLicense:'',
                  registeredCapital:''
                }
            }
        },
        created(){
            this.getTenderList()
        },
        methods:{
            noPass(row){
              let that = this
              let param = {}
              param.platformAuditResults = 2
              param.tenderId = row.tenderId
              let record ={}
              record.tenderId = row.tenderId
              record.auditResult = 2
              this.$confirm('审核未通过, 请确认?', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                center: true
              }).then(() => {
            this.$axios.post('api/finance/tender/modifyTender',param,{headers:{'jwt':localStorage.getItem('jwt')}})
            .then(res=>{
                if(res.data.code==200){
                    that.$axios.post('/api/tenderAudit/insert',record,{headers:{'jwt':localStorage.getItem('jwt')}})
                    .then(res=>{
                        if(res.data.code==200){
                          that.getTenderList()
                            that.$message({
                                message:'审核成功',
                                type:'success'
                            })
                        }else{
                            that.$message({
                                message:'网络异常',
                                type:'error'
                            })
                        }
                    })
                }else{
                    that.$message({
                                message:'网络异常',
                                type:'error'
                            })
                }
            })
        }).catch(() => {
          
        });

              
            },
            pass(row){
              let that = this
              let param = {}
              param.platformAuditResults = 1
              param.tenderId = row.tenderId
              let record ={}
              record.tenderId = row.tenderId
              record.auditResult = 1
              this.$confirm('审核通过, 请确认?', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                center: true
              }).then(() => {
            this.$axios.post('api/finance/tender/modifyTender',param,{headers:{'jwt':localStorage.getItem('jwt')}})
            .then(res=>{
                if(res.data.code==200){
                    that.$axios.post('/api/tenderAudit/insert',record,{headers:{'jwt':localStorage.getItem('jwt')}})
                    .then(res=>{
                        if(res.data.code==200){
                            that.getTenderList()
                            that.$message({
                                message:'审核成功',
                                type:'success'
                            })
                        }else{
                            that.$message({
                                message:'网络异常',
                                type:'error'
                            })
                        }
                    })
                }else{
                    that.$message({
                                message:'网络异常',
                                type:'error'
                            })
                }
            })
        }).catch(() => {
          
        });

            },
            seeCore(row){
              this.dialogFormCore = true
              this.$axios.get()
            },
            doSee(row){
              this.dialogFormVisible = true
              this.$axios.get('api/finance/findFinanceById?enterpriseId='+row.financeId,{headers:{'jwt':localStorage.getItem('jwt')}})
              .then(res =>{
                if(res.data.code==200){
                  console.log(res.data)
                  this.dialogform = res.data.data
                }else{

                }
              })
            },
            doSearchBtn(){
                this.pageNum = 1
                this.getTenderList()
            },
            currentChange(p){
                this.pageNum=p
                this.getTenderList()
            },
            sizeChange(p){
                this.pageNum=1
                this.pageSize=p
                this.getTenderList()
            },
            getTenderList(){
                let param ={}
                param.pageNum = this.pageNum
                param.pageSize = this.pageSize
                let data = {}
                data.financeName = this.financeName
                data.coreName = this.coreName
                param.data = data
                this.$axios.post('api/finance/tender/platformAuditTender',param,{headers:{'jwt':localStorage.getItem('jwt')}})
                .then(res=>{
                    let pageDate = res.data.data
                    this.tableData = pageDate.list
                    this.pageNum = pageDate.pageNum
                    this.pageSize = pageDate.pageSize
                    this.total = pageDate.total
                })
            }
        }
}
</script>

<style scoped>

</style>